package com.cheegu.common.parser.gpsdata.reader.raw;

import java.util.ArrayList;
import java.util.List;

public class TxtRawDataReader extends PathRawDataReader {
    private static final String LINE_SEPARATOR = System.lineSeparator();

    public TxtRawDataReader(String path) {
        super(path);
    }

    @Override
    public String read() {
        StringBuilder sb = new StringBuilder();
        readFile(line -> sb.append(line).append(LINE_SEPARATOR));
        sb.delete(sb.length() - LINE_SEPARATOR.length(), sb.length());
        return sb.toString();
    }

    @Override
    public List<String> readAsList() {
        List<String> ls = new ArrayList<>();
        readFile(ls::add);
        return ls;
    }
}
